<template>
  <a-card :bordered="false">

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-row>
        <a-col :span="19">
      <#if (formColumns?size) gt 2 >
          <a-dropdown v-model="visible" style="text-align: left;">
            <a class="ant-dropdown-link" @click="e => e.preventDefault()">
              搜索条件<a-icon type="down"/>
            </a>
            <a-menu slot="overlay" @click="handleMenuClick">
              <#-- 动态长度  -->
              <#list 3..(formColumns?size)!3 as i>
                  <a-menu-item key="${formColumns[i-1].fieldName}Check">
                    <a-checkbox :checked="${formColumns[i-1].fieldName}Show"></a-checkbox>${formColumns[i-1].uiFieldcomment}</a-menu-item>
              </#list>
            </a-menu>
          </a-dropdown>
      </#if>
        </a-col>
        <a-col :span="5" class="ant-table-right">
          <a-button type="primary" shape="circle" icon="plus"></a-button>
          <a-button class="ant-ui-noborder" icon="bar-chart" >导出</a-button>
          <a-upload name="file" :showUploadList="false" :multiple="false"   >
            <a-button class="ant-ui-noborder" icon="folder-open">导入</a-button>
          </a-upload>
        </a-col>
      </a-row>
    </div>

    <!-- 查询区域 -->
    <#--<div class="table-page-search-wrapper">
      <a-form layout="inline">
        <a-row :gutter="24">
          <#if (formColumns?size) gt 2 >
          <#list 0..1 as i>
            <a-col :md="6" :sm="8">
              <a-form-item label="${formColumns[i].uiFieldcomment}">
                <a-input placeholder="请输入${formColumns[i].uiFieldcomment}" v-model="queryParam.${formColumns[i].fieldName}"></a-input>
              </a-form-item>
            </a-col>
          </#list>
          &lt;#&ndash; 动态长度  &ndash;&gt;
          <#list 3..(formColumns?size)!3 as i>
            <a-col :md="6" :sm="8" v-show="${formColumns[i-1].fieldName}Show">
              <a-form-item label="${formColumns[i-1].uiFieldcomment}">
                <a-input placeholder="请输入${formColumns[i-1].uiFieldcomment}" v-model="queryParam.${formColumns[i-1].fieldName}"></a-input>
              </a-form-item>
            </a-col>
          </#list>
          <#else>
            <#list formColumns as po>
            <a-col :md="6" :sm="8">
            <a-form-item label="${po.uiFieldcomment}">
              <a-input placeholder="请输入${po.uiFieldcomment}" v-model="queryParam.${po.fieldName}"></a-input>
            </a-form-item>
           </a-col>
            </#list>

          </#if>-->


    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline">
        <a-row :gutter="24">
          <#if (formColumns?size) gt 2 >
            <#list 0..1 as i>
              <a-col :md="6" :sm="8">
                <a-form-item label="${formColumns[i].uiFieldcomment}">
                  <#--                <a-input placeholder="请输入${formColumns[i].uiFieldcomment}" v-model="queryParam.${formColumns[i].fieldName}"></a-input>-->
                  <#if formColumns[i].uiUitype =='2'>
                    <a-date-picker style="width: 100%" showTime  v-model="queryParam.${formColumns[i].fieldName}" />
                  <#elseif formColumns[i].uiUitype =='1'>
                    <j-dict-select-tag :triggerChange="true" v-model="queryParam.${formColumns[i].fieldName}"  dictCode="${formColumns[i].uiSelectfunc}">
                    </j-dict-select-tag>
                  <#elseif formColumns[i].uiUitype =='4'>
                    <a-input-number style="width: 100%" v-model="queryParam.${formColumns[i].fieldName}" />
                  <#else>
                    <a-input v-model="queryParam.${formColumns[i].fieldName}"/>
                  </#if>
                </a-form-item>
              </a-col>
            </#list>
          <#-- 动态长度  -->
            <#list 3..(formColumns?size)!3 as i>
              <a-col :md="6" :sm="8" v-show="${formColumns[i-1].fieldName}Show">
                <a-form-item label="${formColumns[i-1].uiFieldcomment}">
                  <#--                <a-input placeholder="请输入${formColumns[i-1].uiFieldcomment}" v-model="queryParam.${formColumns[i-1].fieldName}"></a-input>-->
                  <#if formColumns[i-1].uiUitype =='2'>
                    <a-date-picker style="width: 100%" showTime  v-model="queryParam.${formColumns[i-1].fieldName}" />
                  <#elseif formColumns[i-1].uiUitype =='1'>
                    <j-dict-select-tag :triggerChange="true" v-model="queryParam.${formColumns[i-1].fieldName}"  dictCode="${formColumns[i-1].uiSelectfunc}">
                    </j-dict-select-tag>
                  <#elseif formColumns[i-1].uiUitype =='4'>
                    <a-input-number style="width: 100%" v-model="queryParam.${formColumns[i-1].fieldName}" />
                  <#else>
                    <a-input v-model="queryParam.${formColumns[i-1].fieldName}"/>
                  </#if>
                </a-form-item>
              </a-col>
            </#list>
          <#else>
            <#list formColumns as po>
              <a-col :md="6" :sm="8">
                <a-form-item label="${po.uiFieldcomment}">
                  <#--              <a-input placeholder="请输入${po.uiFieldcomment}" v-model="queryParam.${po.fieldName}"></a-input>-->
                  <#if po.uiUitype =='2'>
                    <a-date-picker style="width: 100%" showTime  v-model="queryParam.${po.fieldName}" />
                  <#elseif po.uiUitype =='1'>
                    <j-dict-select-tag :triggerChange="true" v-model="queryParam.${po.fieldName}"  dictCode="${po.uiSelectfunc}">
                    </j-dict-select-tag>
                  <#elseif po.uiUitype =='4'>
                    <a-input-number style="width: 100%" v-model="queryParam.${po.fieldName}" />
                  <#else>
                    <a-input v-model="queryParam.${po.fieldName}"/>
                  </#if>
                </a-form-item>
              </a-col>
            </#list>

          </#if>



          <a-col :md="6" :sm="8" >
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button  shape="circle" icon="search"></a-button>
              <a  icon="reload" style="margin-left: 8px">重置</a>
              <#--<a @click="handleToggleSearch" style="margin-left: 8px">
                {{ toggleSearchStatus ? '收起' : '展开' }}
                <a-icon :type="toggleSearchStatus ? 'up' : 'down'"/>
              </a>-->
            </span>
          </a-col>

        </a-row>
      </a-form>
    </div>

    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600"></a>项
        <a style="margin-left: 24px" >清空</a>
      </div>

      <a-table
        ref="table"
        size="middle"
        bordered
        :columns="columns"
        >

        <span slot="action" slot-scope="text, record">
          <a >编辑</a>

          <a-divider type="vertical" />
          <a-dropdown>
            <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
            <a-menu slot="overlay">
              <a-menu-item>
                <a-popconfirm title="确定删除吗?" >
                  <a>删除</a>
                </a-popconfirm>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
        </span>

      </a-table>
    </div>
    <!-- table区域-end -->


  </a-card>
</template>

<script>

  export default {
    components: {
    },
    data () {
      return {
        description: '管理页面',

        queryParam:{},

<#if (formColumns?size) gt 2 >
        visible:false,
        //搜索条件控制显隐
        <#list 3..(formColumns?size)!3 as i>
        ${formColumns[i-1].fieldName}Show:false,
        </#list>
</#if>

        // 表头
        columns: [
          {
            title: '#',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
           },
          <#list originalColumns as po>
           <#if po.uiApplist =='true'>
		   {
            title: '${po.uiFieldcomment}',
            align:"center",
            dataIndex: '${po.fieldName}'
           },
		   </#if>
		  </#list>
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            scopedSlots: { customRender: 'action' },
          }
        ],

    }
  },
  computed: {
    importExcelUrl: function(){
      <#noparse>return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;</#noparse>
    }
  },
    methods: {

      <#if (formColumns?size) gt 2 >
      handleMenuClick(e) {
        <#list 3..(formColumns?size)!3 as i>
        if (e.key === '${formColumns[i-1].fieldName}Check') {
          this.${formColumns[i-1].fieldName}Show = !this.${formColumns[i-1].fieldName}Show
        }
        </#list>
      }
      </#if>

     
    }
  }

</script>
<style scoped>
  @import '~@assets/less/common.less'
</style>